home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / bsd / net / netif.h < prev    next >
Text File  |  1995-02-14  |  4KB  |  153 lines

  1. /* 
  2.  * Copyright (C) 1990 by NeXT, Inc., All Rights Reserved
  3.  *
  4.  */
  5.  
  6. /*
  7.  * Network Interface API
  8.  *
  9.  * HISTORY
  10.  * 09-Apr-90  Bradley Taylor (btaylor) at NeXT, Inc.
  11.  *    Created. Some parts originally part of <net/if.h>.
  12.  */
  13. #ifndef _NETIF_
  14. #define _NETIF_
  15.  
  16. #import <net/netbuf.h>
  17.  
  18. /*
  19.  * BEGIN: BSD copyrighted material
  20.  */
  21. /*
  22.  * Copyright (c) 1982, 1986 Regents of the University of California.
  23.  * All rights reserved.  The Berkeley software License Agreement
  24.  * specifies the terms and conditions for redistribution.
  25.  *
  26.  */
  27. #define    IFF_UP        0x1        /* interface is up */
  28. #define    IFF_BROADCAST    0x2        /* broadcast address valid */
  29. #define    IFF_DEBUG    0x4        /* turn on debugging */
  30. #define    IFF_LOOPBACK    0x8        /* is a loopback net */
  31. #define    IFF_POINTTOPOINT    0x10        /* interface is point-to-point link */
  32. #define    IFF_POINTOPOINT    0x10        /* interface is point-to-point link */
  33. #define    IFF_NOTRAILERS    0x20        /* avoid use of trailers */
  34. #define    IFF_RUNNING    0x40        /* resources allocated */
  35. #define    IFF_NOARP    0x80        /* no address resolution protocol */
  36. /* next two not supported now, but reserved: */
  37. #define    IFF_PROMISC    0x100        /* receive all packets */
  38. #define    IFF_ALLMULTI    0x200        /* receive all multicast packets */
  39. #define IFF_D1        0x400        /* For CSLIP */
  40. #define IFF_D2        0x800        /* For CSLIP */    
  41. #define IFF_D3        0x1000        /* For CSLIP */    
  42. #define IFF_COMPAC    IFF_D1        /* For PPP */
  43. #define IFF_COMPPROT    0x2000        /* For PPP */
  44. /*
  45.  * END: BSD copyrighted material
  46.  */
  47.  
  48. #define    IFF_AUTOCONF    0x4000        /* Network is autoconfiguring */
  49. #define IFF_AUTODONE    0x8000        /* Network has autoconfigured */
  50.  
  51. typedef enum netif_class {
  52.     NETIFCLASS_REAL = 0,
  53.     NETIFCLASS_VIRTUAL = 0x1000,
  54.     NETIFCLASS_SNIFFER = 0x2000
  55. } netif_class_t;
  56.  
  57. #ifdef KERNEL
  58.  
  59. extern const char IFCONTROL_SETFLAGS[];
  60. extern const char IFCONTROL_SETADDR[];
  61. extern const char IFCONTROL_GETADDR[];
  62. extern const char IFCONTROL_AUTOADDR[];
  63. extern const char IFCONTROL_UNIXIOCTL[];
  64. extern const char IFCONTROL_ADDMULTICAST[];
  65. extern const char IFCONTROL_RMVMULTICAST[];
  66.  
  67.  
  68. typedef struct if_ioctl {
  69.     unsigned ioctl_command;
  70.     void *ioctl_data;
  71. } if_ioctl_t;
  72.     
  73. typedef struct { char opaque[1]; } *netif_t;
  74.  
  75.  
  76. typedef int (*if_input_func_t)(netif_t netif, netif_t realnetif,
  77.                 netbuf_t nb, void *extra);
  78. typedef int (*if_init_func_t)(netif_t netif);
  79.  
  80. typedef int (*if_output_func_t)(netif_t netif, netbuf_t nb, void *address);
  81. typedef netbuf_t (*if_getbuf_func_t)(netif_t netif);
  82. typedef int (*if_control_func_t)(netif_t netif, const char *command, 
  83.                  void *data);
  84.  
  85. typedef void (*if_attach_func_t)(void *private, netif_t realif);
  86.  
  87. extern int if_output(netif_t netif, netbuf_t packet, void *addr);
  88. extern int if_init(netif_t netif);
  89. extern int if_control(netif_t netif, const char *command, void *data);
  90.  
  91.  
  92. extern int if_ioctl(netif_t netif, unsigned command, void *data);
  93.  
  94. extern netbuf_t if_getbuf(netif_t netif);
  95. extern int if_handle_input(netif_t netif, netbuf_t nb, void *extra);
  96.  
  97.  
  98.  
  99. extern netif_t if_attach(if_init_func_t init_func, 
  100.              if_input_func_t input_func,
  101.              if_output_func_t output_func,
  102.              if_getbuf_func_t getbuf_func,
  103.              if_control_func_t control_func,
  104.              const char *name,
  105.              unsigned unit,
  106.              const char *type,
  107.              unsigned mtu,
  108.              unsigned flags,
  109.              netif_class_t class,
  110.              void *private);
  111.  
  112. extern void if_registervirtual(if_attach_func_t attach_func, void *private);
  113.  
  114. extern void if_detach(netif_t);
  115.  
  116. extern netif_t iflist_first(void);
  117. extern netif_t iflist_next(netif_t);
  118.           
  119. /*
  120.  * Readable attributes
  121.  */
  122. extern const char *if_type(netif_t netif);
  123. extern const char *if_name(netif_t netif);
  124. extern unsigned if_unit(netif_t netif);
  125. extern unsigned if_mtu(netif_t netif);
  126. extern netif_class_t if_class(netif_t netif);
  127. extern void *if_private(netif_t netif);
  128.  
  129. /*
  130.  * Writable attributes 
  131.  */
  132. extern unsigned if_flags(netif_t netif);
  133. extern void if_flags_set(netif_t netif, unsigned flags);
  134.  
  135. extern unsigned if_ipackets(netif_t netif);
  136. extern void if_ipackets_set(netif_t netif, unsigned ipackets);
  137.  
  138. extern unsigned if_opackets(netif_t netif);
  139. extern void if_opackets_set(netif_t netif, unsigned opackets);
  140.  
  141. extern unsigned if_oerrors(netif_t netif);
  142. extern void if_oerrors_set(netif_t netif, unsigned oerrors);
  143.  
  144. extern unsigned if_ierrors(netif_t netif);
  145. extern void if_ierrors_set(netif_t netif, unsigned ierrors);
  146.  
  147. extern unsigned if_collisions(netif_t netif);
  148. extern void if_collisions_set(netif_t netif, unsigned collisions);
  149.  
  150. #endif /* KERNEL */
  151.  
  152. #endif /* _NETIF_ */
  153.